// src/api/booking_api.js
import http from '../../util/request.js'

export default {
    // 添加预约
    add: (obj) => {
        return http({
            url: '/v/booking',
            method: 'POST',
            data: obj,
            headers: {
                'Content-Type': 'application/json'
            }
        });
    },

    // 取消预约
    delete: (id) => {
        return http({
            url: '/v/booking/' + id,
            method: 'DELETE'
        });
    },

    // 修改预约
    edit: (obj) => {
        return http({
            url: '/v/booking',
            method: 'PUT',
            data: obj,
            headers: {
                'Content-Type': 'application/json'
            }
        });
    },
    // 分页查询（根据游客ID查询预约记录）- 修复方法名以匹配前端调用
    page: (params) => {
        // 从参数中提取visitorId
        const { visitorId, ...otherParams} = params;
        return http({
            url: `/v/booking/visitor/${visitorId}`,
            method: 'GET',
            params: otherParams
        });
    }
}

